﻿<%@ Page Title="" Language="C#" MasterPageFile="~/resumemanager/resume.master" Inherits="WebManager.BasePage" %>

<%@ Import Namespace="TalentPools.BLL" %>
<%@ Import Namespace="TalentPools.Model" %>
<script runat="server">

   
    string username;
    protected void btnEidtSubmit_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            CreateresumeManager creater = new CreateresumeManager();
            custom cus = new custom();
            cus.content = txtEditDes.Text.Trim();
            cus.resumeId = Convert.ToInt32(Session["resumeId"]);
            cus.tittle = txtEditTitle.Text.Trim();
            if (new alertResumeManager().updatecustom(cus))
            {
                AddcustomP.Visible = false;
                JsWindows("修改成功！", "EditCustomInfo.aspx");
            }
            else
            {
                lblAdd.Text = "修改自定义信息失败，如果确认填写信息无误，请联系管理员解决！";
            }
        }
    }

    protected void btnsubmit_custom_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            CreateresumeManager creater = new CreateresumeManager();
            custom cus = new custom();
            cus.content = txtcustomtitle.Text.Trim();
            cus.resumeId = Convert.ToInt32(Session["resumeId"]);
            cus.tittle = txtcustomdes.Text.Trim();
            if (creater.createCustom(cus))
            {
                AddcustomP.Visible = false;
                JsWindows("添加成功！", "EditCustomInfo.aspx");
            }
            else
            {
                lblAdd.Text = "添加自定义信息失败，如果确认填写信息无误，请联系管理员解决！";
            }
        }
    }
    private string sf()
    {
        string content = Eval("content").ToString();
        if (content.Length >= 16)
        {
            return content.Substring(0, 15);
        }
        return content;
    }
    /// <summary>
    /// 编辑
    /// </summary>
    private void EditVoid()
    {
        int id = Convert.ToInt32(QueryString("id"));
        AddcustomP.Visible = false;
        manageP.Visible = false;
        EditCustomP.Visible = true;
        custom cus = new CustomManager().GetCustomByCustomId(id);
        txtEditTitle.Text = cus.tittle;
        txtEditDes.Text = cus.content;
    }
    private void ManagerVoid()
    {
        AddcustomP.Visible = false;
        EditCustomP.Visible = false;
        manageP.Visible = true;
        RP1.DataSource = new CustomManager().GetCustom(Convert.ToInt32(Session["resumeId"]));
        RP1.DataBind();
    }
    /// <summary>
    /// 删除
    /// </summary>
    private void DelVoid()
    {

        int id = Convert.ToInt32(QueryString("id"));
        if (new CustomManager().DeleteCustom(id))
        {
            ManagerVoid();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!MyUserLogin())
        {
            JsWindows("请先登录", "../Index.aspx");
            return;
        }
        if (!IsPostBack)
        {
            ManagerVoid();
            string action = QueryString("Action");
            switch (action)
            {
                case "Add":
                    AddcustomP.Visible = true;
                    manageP.Visible = false;
                    EditCustomP.Visible = false;
                    break;
                case "Edit":
                    EditVoid();
                    break;
                case "Del":
                    DelVoid();
                    break;
            }
        }
    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table width='100%' border='0' align='center' cellpadding='4' cellspacing='1' class='border'>
        <tr class='topbg'>
            <td colspan="2" align='center'>
                <strong class="Glow">自 定 义 信 息 管 理</strong>
            </td>
        </tr>
        <tr class='tdbg'>
            <td width='70'>
                <strong>导航：</strong>
            </td>
            <td>
                <a href="?Action=Add">添加自定义信息</a> | <a href="?Action=Show">自定义信息列表</a>
            </td>
        </tr>
    </table>
    <asp:Panel ID="AddcustomP" runat="server" Visible="false">
        <table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
            <tr class='tdbg'>
                <td colspan="2" class="topbg2">
                    <div align="center" class="Glow">
                        <strong>新 增 自 定 义 信 息</strong></div>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>自定义标题：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtcustomtitle" runat="server"></asp:TextBox>
                    <span class="style4" style="color: #333">
                        <asp:RequiredFieldValidator ControlToValidate="txtcustomtitle" ID="RequiredFieldValidator15"
                            runat="server" ErrorMessage="请输入自定义标题"></asp:RequiredFieldValidator>
                    </span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>详细描述：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtcustomdes" runat="server" Height="138px" TextMode="MultiLine"
                        Width="343px"></asp:TextBox>
                    <span class="style4" style="color: #333">
                        <asp:RequiredFieldValidator ControlToValidate="txtcustomdes" ID="RequiredFieldValidator16"
                            runat="server" ErrorMessage="请输入自定义内容"></asp:RequiredFieldValidator>
                    </span>
                </td>
            </tr>
        </table>
        <br />
        <table width="100%" border="0">
            <tr>
                <td>
                    <div align="center">
                        &nbsp;<asp:Button ID="btnsubmit_custom" runat="server" Text="提 交" OnClick="btnsubmit_custom_Click" />
                        &nbsp;
                        <label>
                            <input type="reset" name="Submit2" value="重 置" /><br />
                            <asp:Label ID="lblAdd" runat="server" ForeColor="Red"></asp:Label></label></div>
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="EditCustomP" runat="server" Visible="false">
        <table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
            <tr class='tdbg'>
                <td colspan="2" class="topbg2">
                    <div align="center" class="Glow">
                        <strong>编 辑 自 定 义 信 息</strong></div>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>自定义标题：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtEditTitle" runat="server"></asp:TextBox>
                    <span class="style4" style="color: #333">
                        <asp:RequiredFieldValidator ControlToValidate="txtEditTitle" ID="RequiredFieldValidator1"
                            runat="server" ErrorMessage="请输入自定义标题"></asp:RequiredFieldValidator>
                    </span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>详细描述：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtEditDes" runat="server" Height="138px" TextMode="MultiLine" Width="343px"></asp:TextBox>
                    <span class="style4" style="color: #333">
                        <asp:RequiredFieldValidator ControlToValidate="txtEditDes" ID="RequiredFieldValidator2"
                            runat="server" ErrorMessage="请输入自定义内容"></asp:RequiredFieldValidator>
                    </span>
                </td>
            </tr>
        </table>
        <br />
        <table width="100%" border="0">
            <tr>
                <td>
                    <div align="center">
                        &nbsp;<asp:Button ID="btnEidtSubmit" runat="server" Text="提 交" OnClick="btnEidtSubmit_Click" />
                        &nbsp;
                        <label>
                            <input type="reset" name="Submit2" value="重 置" /><br />
                            <asp:Label ID="lblEdit" runat="server" ForeColor="Red"></asp:Label></label></div>
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="manageP" runat="server" Width="100%" Visible="False">
        <table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
            <tr class='topbg2'>
                <td width="7%" align='center' style="height: 24px">
                    <strong class="Glow">序号</strong>
                </td>
                <td width="12%" align='center' style="color: #000000; height: 24px">
                    <strong class="Glow">标题</strong>
                </td>
                <td width="25%" align='center' style="height: 24px">
                    <strong class="Glow">内容</strong>
                </td>
                <td width="14%" align='center' style="height: 24px">
                    <strong class="Glow">操作</strong>
                </td>
            </tr>
            <asp:Repeater ID="RP1" runat="server">
                <ItemTemplate>
                    <tr class='tdbg'>
                        <td align='center'>
                            <%#Eval("customId")%>
                        </td>
                        <td align='center'>
                            <%#Eval("tittle") %>
                        </td>
                        <td align='center'>
                            <%#sf() %>
                        </td>
                        <td align='center'>
                            <a href="EditCustomInfo.aspx?id=<%#Eval("customId")%>&amp;Action=Edit">修改</a> |
                            <a href="EditCustomInfo.aspx?id=<%#Eval("customId") %>&amp;Action=Del" onclick="return confirm('确定要删除此项吗？此操作不可逆。');">
                                删除</a>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>
    </asp:Panel>
</asp:Content>
